#include<bits/stdc++.h>
using namespace std;
struct node{
	int num;
	int val;
	node(int n,int v){
		num=n,val=v;
	}
	node(){
		num=0,val=0;
	}
	bool operator >(const node a)const {
		if(val!=a.val)return val>a.val;
		return num>a.num;
	}
	bool operator <(const node a)const {
		if(val!=a.val)return val<a.val;
		return num<a.num;
	}
};
int n,q;
node a[8010];
int mp[8010];
void init(){
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		int t;
		cin>>t;
		a[i]=node(i,t);
	}
	for (int i = 1; i <= n; i++){
   	    for (int j = i; j>=2; j--){
		    if ( a[j] < a[j-1] ){
   				node t = a[j-1];
   				a[j-1] = a[j];
   				a[j] = t;
   			}
		}
   	}
   	for(int i=1;i<=n;i++){
   		mp[a[i].num]=i;
	}
}
int main(){
	init();
	for(int r=0;r<q;r++){
		int type;
		cin>>type;
		if(type==1){
			int x,v;
			cin>>x>>v;
			node tmp=a[mp[x]];
			tmp.val=v;
			int l=1,r=n;
			int p;
			while(l<r-1){
				int mid=(l+r)/2;
				if(a[mid]>tmp)r=mid;
				else l=mid;
			} 
			
			if(mp[x]>=r){
				p=r;
				for(int i=mp[x]-1;i>=p;i--){
					a[i+1]=a[i];
					mp[a[i+1].num]=i+1;
				}
			}else{
				p=l;
				for(int i=mp[x]+1;i<=p;i++){
					a[i-1]=a[i];
					mp[a[i].num]=i-1;
				}
			}
			a[p]=tmp;
			mp[x]=p;
		}
		if(type==2){
			int x;
			cin>>x;
			cout<<mp[x]<<endl;
		}
	}
	return 0;
}
